function quickSort(arr){
    if(arr===null||arr.length<2){
        return;
    }

    quickSortCal(arr,0,arr.length-1);
    return arr;
}

function quickSortCal(arr,left,right){
    if(left<right){
        let p = partition(arr,left,right);
        quickSortCal(arr,left,p-1);
        quickSortCal(arr,p+1,right);
    }
}

function partition(arr,left,right){
    if(left<right){
        let p = arr[right];
        let bounder = left-1;
        for(let i=0;i<arr.length;i++){
            if(arr[i]<=p){
                swap(arr,++bounder,i);
            }
        }
        return bounder;
    }
}

function swap(arr,i,j){
    [arr[i],arr[j]]  = [arr[j],arr[i]];
}

let arr = [11, 1,5,30,80,98];
console.log(quickSort(arr, 3));